namespace Telerik.RadCartesianChartSample.Common.ViewModel
{
    using Model;
    using System;
    using System.Collections.ObjectModel;
    using System.Linq;

    public class DashboardViewModel : NotifyPropertyChanged
    {
        private Random _random;

        public DashboardViewModel()
        {
            Init();
        }

        private void Init()
        {
            _random = new Random();
            DashBoardItems = new ObservableCollection<BoardItem>
                {
                    new BoardItem
                        {
                            Name = "Blue",
                            Value = 1, 
                            Count = _random.Next(20,50)
                        },
                    new BoardItem
                        {
                            Name = "Pink", 
                            Value = 2, 
                            Count = _random.Next(20,100)
                        },
                    new BoardItem
                        {
                            Name = "Yellow", 
                            Value = 3,
                            Count =  _random.Next(20,100)
                        }
                };
        }

        public int MajorStep
        {
            get
            {
                if (DashBoardItems.Any(item => item.Count < 10))
                {
                    return 1;
                }

                if (DashBoardItems.Any(item => item.Count > 50))
                {
                    return 5;
                }

                return 2;
            }
        }

        public ObservableCollection<BoardItem> DashBoardItems { get; set; }
    }
}